﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
using IndicoInterface;

namespace FetchAgendaXML
{
    class Program
    {
        /// <summary>
        /// Fetch a meeting and conference URL so that we can get teh XML into a file we can analyze for later use.
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            SaveConferenceToFile(14475, "workshop.xml");
            SaveConferenceToFile(33078, "meeting.xml");
        }
        

        /// <summary>
        /// Download the XML from a meeting and stash it in a file.
        /// </summary>
        /// <param name="p"></param>
        /// <param name="p_2"></param>
        private static void SaveConferenceToFile(int confID, string filename)
        {
            AgendaInfo a = new AgendaInfo(confID);
            WebRequest req = WebRequest.Create(a.AgendaFullXML);
            using (WebResponse res = req.GetResponse())
            {
                TextReader r = new StreamReader(res.GetResponseStream());
                string data = r.ReadToEnd();

                using (TextWriter wr = File.CreateText(filename))
                {
                    wr.Write(data);
                }
                res.Close();
            }
        }
    }
}
